//  添加Code能力 变成code代码

function code (font) {
  // Google翻译
  if (font) {
    if (font.length !== 0 && font.length !== undefined) {
      // 处理元素群
      for (let i = 0; i < font.length; i++) {
        code_template(font[i])
      }
    } else {
      // 处理单个元素
      if (font.nodeType === 1 && font.innerHTML) {
        code_template(font)
      }
    }
  }
}

// google 生成notranslate即可,  彩云生成cyxy-trs-source-ted
// eslint-disable-next-line camelcase
function code_template (font) {
  if (font) {
      const hasClassAttribute = font.getAttribute('class')
          font.setAttribute('class', `${hasClassAttribute} notranslate`)
        }
}

export { code, code_template }
